package com.lerays.yuan.AI_Robot.util;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.MissingResourceException;
import java.util.Properties;
import java.util.ResourceBundle;
 
/**
 * 获取配置资源文件 [公共参数] 信息
 * @author Henry_zp
 */
public class CommonParam {
        private String propertyFileName;
        private ResourceBundle resourceBundle;
        public CommonParam() {
                propertyFileName = "/config.properties";
           // resourceBundle = ResourceBundle.getBundle(propertyFileName);
        }
        public String getString(String key)  {
               
                if (key == null || key.equals("") || key.equals("null")) {
                      return "";
                 }
                Properties properties = new Properties();  
                InputStream inputStream = this.getClass().getResourceAsStream(propertyFileName);  
                BufferedReader bf = new BufferedReader(new InputStreamReader(inputStream));  
                try {
                        properties.load(bf);
                } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }  
                return properties.getProperty(key);
                
//            if (key == null || key.equals("") || key.equals("null")) {
//                return "";
//            }
//            String result = "";
//            try {
//                result = resourceBundle.getString(key);
//            } catch (MissingResourceException e) {
//                e.printStackTrace();
//            }
//            return result;
        }
}